package com.lcf.order.mq;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lcf.order.common.ProductInfoOutput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Slf4j
public class RabbitMqReciver {

    @RabbitListener(queuesToDeclare = @Queue("productInfo2"))
    public void getCartDto(String msg) {
        log.info("监听到的消息{}", msg);
    }

    @RabbitListener(queuesToDeclare = @Queue("productInfo"))
    public void getProductInfo(String msg) {
        List<ProductInfoOutput> productInfoOutput = JSONObject.parseArray(msg, ProductInfoOutput.class);
        log.info("监听到【{}】的消息{}","productInfo",productInfoOutput );
    }
}
